package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.FaceCheckRecord;
import com.sc.nft.mapper.FaceCheckRecordMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.util.List;


@Slf4j
@Repository
public class FaceCheckRecordDao extends ServiceImpl<FaceCheckRecordMapper, FaceCheckRecord> {

    public List<FaceCheckRecord> getNewByUserId(Long userId) {
        LambdaQueryWrapper<FaceCheckRecord> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(FaceCheckRecord::getUserId, userId);
        lambdaQueryWrapper.orderByDesc(FaceCheckRecord::getCreateTime);
        lambdaQueryWrapper.last("limit 1");
        return list(lambdaQueryWrapper);
    }
}
